package br.pucrs.lognplay.faces.bean;

import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import br.pucrs.lognplay.entity.DynamicView;
import br.pucrs.lognplay.service.DynamicViewManagementService;

@ManagedBean
@RequestScoped
public class DynamicViewListBean extends Bean {

	private List<DynamicView> dynamicViews;

	@EJB
	private DynamicViewManagementService dynamicViewManagementService;

	public List<DynamicView> getDynamicViews() {
		try {
			if (dynamicViews == null) {
				dynamicViews = dynamicViewManagementService.listAllDynamicViews();
			}

			return dynamicViews;
		} catch (Exception e) {
			throw new BeanException("Unexpected error", e);
		}
	}
}
